package com.ideal.manage.esms.compoment;

import com.ideal.manage.esms.service.esms.EsmsDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class SetupLineRunner implements CommandLineRunner {
    private static final Logger LOG = LoggerFactory.getLogger(SetupLineRunner.class);
    @Autowired
    private EsmsDataService esmsDataService;

    @Override
    public void run(String... args) {
        LOG.info("初始化系统");
        String typeName = "mdbs";
        String index = "mdbs-" + new SimpleDateFormat("yyyy.MM.dd").format(new Date());
        try {
            esmsDataService.createTodayIndex(index, typeName);
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        }
    }
}
